<%@page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.nobody.facepk.pojo.SessionUser"%>
<%@page import="com.nobody.facepk.model.Picture"%>
<%@page import="com.nobody.facepk.model.Friends"%>
<%@page import="com.nobody.facepk.model.User"%>
<%@page import="com.nobody.facepk.service.UserService"%>
<%@page import="java.util.Set"%>
<%@page import="java.util.List;"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>FacePk</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  <%
  SessionUser user = (SessionUser)request.getSession().getAttribute("SESSION_USER");
  List  pictures = (List)request.getAttribute("pictures");
  int picturesSize = pictures.size();
  
  List myFriends = (List)request.getAttribute("friends");
  
  %>
  <body>
    欢迎<%=user.getName()%>来到FacePk <br>
    <form action="" method="post">  
    <table>
    	我的好友:
    	<%
    		for(int i = 0 ; i < myFriends.size() ; i ++){
    		User friend = (User)myFriends.get(i);
    		%>
    		<a href=""><%=friend.getName()%></a>
    		<%
    		}
	    	 %>
    	<br/><a href="addFriend.jsp">添加好友</a>
    </table>
        <table>
    	我的照片:<br/>
    	<%
    	if(picturesSize == 0 ){%>
    	暂无图片。
    	<%}else{
    	if(picturesSize>4) picturesSize = 4; //首页最多显示4张
    	for(int i = 0 ; i < picturesSize ; i ++){
    	Picture  pic  = (Picture)pictures.get(i);
    	String picPath = pic.getPath();
    	String picName = pic.getName();
    	String realPath = "pictures/"+user.getUserId()+"/"+picPath;
    	System.out.println("realPath ="+realPath);
    	%>
    	<a href=""><img src="<%=realPath %>" height="80" width="80"/></a>
    	
    	<%
            }
    	 }
    	%>
   		<br/><a href="upload.jsp">上传</a>
   			 </table>
   	
   			 <table>
    	我的信息:
		</table>
    </form>
  </body>
    
</html>
